package com.xl.exercise;

public class Test1 {
    public static void main(String[] args) {
        //完成买飞机票的案例
        double price = calculatePrice(1000,8, "经济舱");
        System.out.println("优惠价是:"+price+"元");
    }

    public static double calculatePrice(double price, int month, String type) {
        //判断当前月份是淡季还是旺季
        if (month >= 5 && month <= 10) {
            //如果是旺季，根据不同的舱位价格不同
            return switch (type) {
                case "头等舱" -> price * 0.9;
                case "经济舱" -> price * 0.85;
                default -> price;
            };
        } else {
            //如果是淡季，根据不同的舱位价格不同
            return switch (type) {
                case "头等舱" -> price * 0.7;
                case "经济舱" -> price * 0.65;
                default -> price;
            };
        }
    }
}
